﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Heart : MonoBehaviour
{


    //精灵渲染器
    private SpriteRenderer spriteRenderer;
    //心脏破碎引用
    public Sprite brokenSprite;
    //爆炸效果引用
    public GameObject explosionPrefab;

    // Start is called before the first frame update
    void Start()
    {
        //初始化渲染器
        spriteRenderer = GetComponent<SpriteRenderer>();
    }

    // Update is called once per frame
    void Update()
    {

    }

    public void HeartDie()
    {
        // 破碎图片替换
        spriteRenderer.sprite = brokenSprite;
        //爆炸效果
        Instantiate(explosionPrefab, transform.position, transform.rotation);
    }
}
